#include "mypushbotton.h"
#include<QDebug>
#include<QPropertyAnimation>
myPushBotton::myPushBotton(QString normalImg, QString pressImg)//记得添加作用域
{
    this->normalImgPath = normalImg;
    this->pressImgPath= pressImg;
    QPixmap pix;
    bool ret = pix.load(normalImg);
    if(!ret)
    {
        qDebug() << "图片加载失败";
        return;
    }
    this->setFixedSize(pix.width(),pix.height());
    this->setStyleSheet("QPushButton{border:0px;}");
    this->setIcon(pix);
    this->setIconSize(QSize(pix.width()*0.8,pix.height()*0.8));

}
void myPushBotton::zoom1()//设置跳起动画
{
    QPropertyAnimation * ani = new QPropertyAnimation(this,"geometry");
    ani->setDuration(500);//时间间隔
    ani->setStartValue(QRect(this->x(),this->y(),this->width(),this->height()));
    ani->setEndValue(QRect(this->x(),this->y()+10,this->width(),this->height()));
    ani->setEasingCurve(QEasingCurve::OutBounce);//设置弹跳曲线
    ani->start();
}
void myPushBotton::zoom2()//设置跳起动画
{
    QPropertyAnimation * ani = new QPropertyAnimation(this,"geometry");
    ani->setDuration(500);//时间间隔
    ani->setStartValue(QRect(this->x(),this->y()+10,this->width(),this->height()));
    ani->setEndValue(QRect(this->x(),this->y(),this->width(),this->height()));
    ani->setEasingCurve(QEasingCurve::OutBounce);//设置弹跳曲线
    ani->start();
}
void myPushBotton::grab()
{
    QPropertyAnimation * ani = new QPropertyAnimation(this, "pos");
    ani->setDuration(1000);
    ani->setStartValue(QPoint(this->x(),this->y()));
    ani->setEndValue(QPoint(720, 400));
    ani->setEasingCurve(QEasingCurve::OutQuad);//设置弹跳曲线
    ani->start();
}
void myPushBotton::pour()
{
    QPropertyAnimation * ani = new QPropertyAnimation(this, "pos");
    ani->setDuration(2000);
    ani->setStartValue(QPoint(this->x(), this->y()));
    ani->setEndValue(QPoint(720, 200));
    ani->setEasingCurve(QEasingCurve::OutQuad);//设置弹跳曲线
    ani->start();
}



